﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using WLMCoreLibrary;
using MiWebSite_Core;


namespace MWS_AddDirectory.categorias
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            WebSiteMainConfiguration config = WebSiteMainConfiguration.GetConfig();          

            if (Request["xml"] != null)
            {
                try
                {
                    dbConnector ConexionDB = new dbConnector();
                    MiWebSitePage pagina = new MiWebSitePage(ref ConexionDB);
                    pagina.Title = "Directorio de " + DeCurrentDomain.Ciudad;
                    pagina.DomainName = DeCurrentDomain.DomainName;
                    pagina.DomainID = DeCurrentDomain.IdentificadorDominio;
                    CategoriaCollection listaCategorias = new CategoriaCollection(ref ConexionDB);

                    pagina.Contenido = WLMFunctions.SerializeObject(listaCategorias);

                    Response.ContentType = "text/xml";
                    Response.Write(WLMFunctions.SerializeObject(pagina).InnerXml);
                    ConexionDB.CloseConnection();
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                string HTMLPagina = WLMFunctions.TransformXML(Request.Url.AbsoluteUri + "?xml=true", config.Settings["siteURL"].value + config.Settings["skinPath"].value + "index.xsl", FuncionesDirectorio.GetTransformationParameters());
                Response.Write(HTMLPagina);

            }
        }
    }
}